home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Transactor
/
Transactor_23_1988_Transactor_Publishing.d64
/
basic time
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2023-02-26
|
2KB
|
65 lines
50000 rem subroutine to get time from
50005 rem user and convert for ti$ and
50010 rem the tod clock in cia #1.
50015 :
50020 rem by noel nyman
50025 :
50030 rem called as a subroutine
50035 :
50040 rem uses the following variables
50045 rem ap - am/pm flag, am=0 pm=1
50050 rem ht - hours, used for tod
50055 rem mt - minutes, used for tod
50060 rem sc - seconds, used for tod
50065 rem tt - temporary variable
50070 rem tt% - temporary variable
50075 rem ht$ - hours for ti$
50080 rem mt$ - minutes for ti$
50085 rem st$ - seconds for ti$
50090 rem tt$ - temporary for ti$
50095 rem ap$ - temporary variable
50099 :
50100 print "current time is " left$(ti$,2) ":" mid$(ti$,3,2) ":";
50110 print right$(ti$,2)
50120 print: print "enter new time, or \ [146] to quit"
50130 print: print "enter new hours (0-23): ";
50140 open 9,0: input#9,ht$: close9
50150 if ht$="\" then return
50160 ht=val(ht$): if ht<0 or ht>23 goto 50130
50170 ap=0-(ht>12)
50180 :
50200 print: print "enter new minutes (0-59): ";
50210 open 9,0: input#9,mt$: close9
50220 mt=val(mt$): if mt<0 or mt>59 goto 50200
50230 if len(mt$)<2 then mt$="00"+mt$
50240 :
50300 print: print "enter new seconds (0-59): ";
50310 open 9,0: input#9,st$: close9
50320 sc=val(st$): if sc<0 or sc>59 goto 50300
50330 if len(st$)<2 then st$="00"+st$
50340 :
50400 if ap goto 50500
50410 print: if ht<12 goto 50460
50420 print "am or noon (a/n)?";
50430 get ap$: if ap$="" goto 50430
50440 if ap$<>"a" and ap$<>"[193]" and ap$<>"n" and ap$<>"[206]" goto 50430
50450 ap=0-(ap$="n")-(ap$="[206]"): goto 50500
50460 print "am or pm (a/p)?";
50470 get ap$: if ap$="" goto 50470
50480 if ap$<>"a" and ap$<>"[193]" and ap$<>"p" and ap$<>"[208]" goto 50470
50490 ap=0-(ap$="p")-(ap$="[208]")
50500 ht=ht+12*((ht=12) and (ap=0))
50510 ht=ht-12*((ht<12) and (ap=1))
50520 ht$=str$(ht): ht$="00"+right$(ht$,len(ht$)-1)
50530 tt$=right$(ht$,2)+right$(mt$,2)+right$(st$,2): ti$=tt$
50540 tt=0: if ht>12 then ht=ht-12: tt=128
50550 tt%=ht/10: tt=tt+(16*tt%)+(ht-10*tt%)
50560 poke 56335,peek(56335) and 127
50570 poke 56331,tt
50580 tt%=mt/10: tt=(16*tt%)+(mt-10*tt%)
50590 poke 56330,tt
50600 tt%=sc/10: tt=(16*tt%)+(sc-10*tt%)
50610 poke 56329,tt
50620 poke 56328,0
50630 print: goto 50100